package com.freecloud.whispered.auth.config;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @Author: maomao
 * @Date: 2019-06-16 22:24
 */
@Configuration
public class KaptchaConfig {
    @Bean
    public DefaultKaptcha producer() {
        Properties kaptchaProperties = new Properties();
        kaptchaProperties.put("kaptcha.border", "no");

        kaptchaProperties.put("kaptcha.textproducer.font.color", "black");
        kaptchaProperties.put("kaptcha.textproducer.char.space", "5");
        kaptchaProperties.put("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");

//        kaptchaProperties.put("kaptcha.textproducer.char.length","4");
//        kaptchaProperties.put("kaptcha.image.height","50");
//        kaptchaProperties.put("kaptcha.image.width","150");
//        kaptchaProperties.put("kaptcha.obscurificator.impl","com.google.code.kaptcha.impl.ShadowGimpy");
//        kaptchaProperties.put("kaptcha.textproducer.font.color","black");
//        kaptchaProperties.put("kaptcha.textproducer.font.size","40");
//        kaptchaProperties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.NoNoise");
//        kaptchaProperties.put("kaptcha.noise.impl","com.google.code.kaptcha.impl.DefaultNoise");
//        kaptchaProperties.put("kaptcha.textproducer.char.string","acdefhkmnprtwxy2345678");

        Config config = new Config(kaptchaProperties);
        DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
        defaultKaptcha.setConfig(config);
        return defaultKaptcha;
    }
}
